import com.alibaba.fastjson.JSON;
import io.netty.channel.Channel;
import lombok.extern.slf4j.Slf4j;
import org.nettyServer.command.CommandBase;
import org.nettyServer.eunm.EMessageCode;
import org.nettyServer.messageHandle.MessageInfoRecord;


@Slf4j
public class ClientPushUtils {

    public static void pushMessage(String msgCode,Object obj, Channel channel) {
        CommandBase commandBase = CommandBase.builder()
                .commandCode(msgCode)
                .data(JSON.toJSONString(obj))
                .build();
        String jsonString = JSON.toJSONString(commandBase);
        log.info("消息类型: [{}], 发出消息: {}", EMessageCode.getEnumByCode(msgCode), jsonString);
        byte[] bytes = ( jsonString+ "\n").getBytes();
        channel.writeAndFlush(bytes);
    }

}
